package com.itheima.mapper;

import com.itheima.entity.Emp;
import com.itheima.entity.Fenlei;
import com.itheima.entity.PageQueryBean;
import com.itheima.entity.Yuang;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
/*
* 查询emp用户表总记录数
* @return
*
* */
   /* @Select("select count(*) from tlias_web_db.emp")
    Integer count();*/

/*
* 查询指定页的员工数据
* @param begin
* @param pageSize
* @return
*
*
* */
   /* @Select("select *from tlias_web_db.emp limit #{begin},#{pageSize}")
    List<Emp> selectByPage(Integer begin, Integer pageSize);*/


    List<Emp> selectByPage(PageQueryBean pageQueryBean);

/*
*  批量删除员工
* @param ids
*
* */
    void delete(List<Integer> ids);

    //添加员工信息
    void insert(Emp emp);
    // 根据id
    @Select("select *from emp.emp where id = #{id}")
    Emp queryOne(Integer id);
    //更新
    void update(Emp emp);
/*
* 根据用户名密码查询员工信息
*
* */
    @Select("select *from emp.emp where username =#{username}")
    Emp selectByNameAndPwd(Emp emp);



    // 员工管理分页查询员工
    @Select("select count(*) from db_emp.employee")
    Integer count();
    // 员工管理分页查询员工
    @Select("select *from db_emp.employee limit #{page},#{pageSize}")
    List<Class> pageQuery(Integer page, Integer pageSize);
    //员工管理添加员工
    void add(Yuang yuang);
     //员工管理根据id查询
     @Select("select *from db_emp.employee where id = #{id}")
    Emp query(Integer id);
    /*
     * 员工管理更新员工
     * */
    void updated(Yuang yuang);
    /*
     *员工登录，退出
     * */
    @Select("select *from db_emp.employee where username =#{username} and password =#{password}")
    Emp selectByNameAndPw(Yuang yuang);
    /*
     *禁用/启用员工
     * */
    @Select("select *from db_emp.employee where id = #{id}")
    Emp selectByNameAndP(Integer id);
    /*
     * 修改
     * */
    void xiuugai(Fenlei fenlei);
    /*
     * 新增分类
     *
     * */
    @Insert("insert into category.category(id, name, create_time, update_time) values (null,#{name},#{createTime},#{updateTime});")
    void inser(Fenlei fenlei);
    /*
     * 根据id删除分类
     * */
    @Delete("delete from category.category where id = #{id}")
    void deleteBuId(Integer id);
    /*
     *禁用/启用分类
     * */
    @Select("select *from category.category where id = #{id}")
    Emp selectByNameAnd(Integer id);
  //分页
  @Select("select *from category.category limit #{page},#{pageSize}")
    List<Fenlei> pageQuer(Integer page, Integer pageSize);
    //根据类型查询
    @Select("select * from category.category")
    void fen(Map map);
    @Delete("delete from emp.emp where dept_id = #{id}")
    void deleteBydeptId(Integer id);
}
